define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'car/index/index' + location.search,
                    table: 'car',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                commonSearch: true,
                visible: true,
                showToggle: false,
                showColumns: false,
                search:false,
                searchFormVisible:true,
                showExport: false,
                columns: [
                    [
                        {field: 'id', title: '车辆ID',operate: false},
                        {field: 'member.member_name', title: '车主', operate: 'LIKE'},
                        {field: 'brand.logo', title: __('Logo'),  formatter: Table.api.formatter.image, events: Table.api.events.image,operate: false},
                        {field: 'brand.name', title: '品牌', operate: 'LIKE'},
                        {field: 'series.name', title: '系列', operate: 'LIKE'},
                        {field: 'car_numbers', title: '车牌号', operate:'LIKE'},
                        {field: 'mileage', title: '里程(单位：KM)', operate:false,sortable: true},
                        {field: 'vin', title: '车架号', operate:'LIKE'},
                        {field: 'travel_time', title: '上牌时间',sortable: true, operate:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime, datetimeFormat:"YYYY-MM-DD"},
                        {field: 'car_type', title: '类型', formatter: Table.api.formatter.flag, searchList: {1:"燃油车", 2:"纯电", 3: "混动"}},
                        {field: 'createtime', title: '添加时间', operate:false,sortable: true, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
